#pragma once
#include <iostream>
#include <unistd.h>
#include "Util.hpp"
#include <vector>
#include "Log.hpp"
class HttpRequest
{
public:
    std::string _request_line;
    std::vector<std::string> _request_head;
    std::string _blank;
    std::string _body;
};

class HttpResponse
{
public:
    std::string _state_line;
    std::vector<std::string> _response_head;
    std::string _blank;
    std::string _response_body;
};

class EndPoint
{
private:
    int _sock;
    HttpRequest _http_requset;
    HttpResponse _http_response;

private:
    void RecvHttpRequestLine()
    {
        Util::ReadLine(_sock,_http_requset._request_line);
    }

    void RecvHttpRequestHeader()
    {
        
    }

    void RecvHttpRequestBody()
    {}
   

public:
    EndPoint(int sock) : _sock(sock)
    {
    }

    void RecvHttpRequest()
    {
    }

    void ParseHttpRequest()
    {
    }

    void BuildHttpResponse()
    {
    }

    void SendHttpResponse()
    {
    }

    ~EndPoint()
    {
        close(_sock);
    }
};

class Entrance
{
public:
    static void *HandlerRequest(void *args)
    {
        LOG(INFO,"Handler Request Being...");
        int sock = *(int *)args;
        delete (int *)args;

        // std::cout<<"get a new link.... : "<<sock<<std::endl;
        EndPoint* ep=new EndPoint(sock);
        ep->RecvHttpRequest();
        ep->ParseHttpRequest();
        ep->BuildHttpResponse();
        ep->SendHttpResponse();
        delete ep;

        LOG(INFO,"Handler Request End");
        close(sock);
        return nullptr;
    }
};